

#import "PUBaseViewController.h"
#import "PUNavigationController.h"
@interface PUBaseViewController ()

@end

@implementation PUBaseViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 初始化UI
    [self initViews];
}

// 初始化UI
- (void)initViews {
    
}

//- (void)showLoading:(NSString *)str{
//    self.hud.label.text = str;
//    [self.hud showAnimated:YES];
//}
//
///**
// *  隐藏HUD
// */
//- (void)hideLoading {
//    [self.hud hideAnimated:YES];
//}
//- (void)hideLoading:(NSTimeInterval)time {
//    [self.hud hideAnimated:YES afterDelay:time];
//}

#pragma mark - Push
- (void)pushStoryboard:(NSString *)pushStoryboardName VCIdentifier:(NSString *)pushName params:(NSDictionary<NSString *, id> *)params {
    PUBaseViewController *pushVC = [[UIStoryboard storyboardWithName:pushStoryboardName bundle:nil] instantiateViewControllerWithIdentifier:pushName];
    if (params) {
        for (NSString *key in params) {
            [pushVC setValue:params[key] forKey:key];
        }
    }
    
    [self.navigationController pushViewController:pushVC animated:YES];
    
}

- (void)push:(NSString *)pushName params:(NSDictionary<NSString *, id> *)params {
    
    Class clazz = NSClassFromString(pushName);
    PUBaseViewController *pushVC = [[clazz alloc] init];
    
    if (params) {
        for (NSString *key in params) {
            [pushVC setValue:params[key] forKey:key];
        }
    }
    
    [self.navigationController pushViewController:pushVC animated:YES];
}

- (void)presentStoryboard:(NSString *_Nullable)pushStoryboardName VCIdentifier:(NSString *_Nullable)pushName params:(NSDictionary<NSString *, id> *_Nullable)params{
    PUBaseViewController *pushVC = [[UIStoryboard storyboardWithName:pushStoryboardName bundle:nil] instantiateViewControllerWithIdentifier:pushName];
    if (params) {
        for (NSString *key in params) {
            [pushVC setValue:params[key] forKey:key];
        }
    }
    PUNavigationController *navVc = [[PUNavigationController alloc] initWithRootViewController:pushVC];
    navVc.modalPresentationStyle = 0;
    [self presentViewController:navVc animated:YES completion:nil];
}

- (void)present:(NSString * _Nonnull)pushName params:(NSDictionary<NSString *, id> *__nullable)params{
    Class clazz = NSClassFromString(pushName);
    PUBaseViewController *pushVC = [[clazz alloc] init];
    
    if (params) {
        for (NSString *key in params) {
            [pushVC setValue:params[key] forKey:key];
        }
    }
//    [self presentViewController:pushVC animated:YES completion:nil];
    
    PUNavigationController *navVc = [[PUNavigationController alloc] initWithRootViewController:pushVC];
    navVc.modalPresentationStyle = 0;
    [self presentViewController:navVc animated:YES completion:nil];
}


#pragma mark - Pop
- (void)pop {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)popToRoot {
    [self.navigationController popToRootViewControllerAnimated:YES];
}
//- (void)showAlertWithMessage:(NSString *)msg {
//    [UIAlertController showInfoAlertVCInVC:self message:msg ok:nil];
//}
//
//- (void)showAlertWithMessage:(NSString *)msg ok:(void (^ __nullable)(void))okHandler {
//    [UIAlertController showInfoAlertVCInVC:self message:msg ok:okHandler];
//}
//
//- (void)showAlertWithMessage:(NSString *)msg ok:(void (^ __nullable)(void))okHandler cancel:(void (^ __nullable)(void))cancelHandler {
//    [UIAlertController showNormalAlertVCInVC:self message:msg style:UIAlertControllerStyleAlert ok:okHandler cancel:cancelHandler];
//    
//}
//- (void)showAlertWithMessage:(NSString *)msg title:(NSString *)title
//textfield:(void (^ __nullable)(UITextField *textField))textfieldHandler
//confirm:(void (^ __nullable)(void))confirmHandler
//cancel:(void (^ __nullable)(void))cancelHandler {
//    [UIAlertController showTextFiledAlertVCInVC:self
//                                        message:msg
//                                          title:title
//                                          style:UIAlertControllerStyleActionSheet
//                                      textfield:textfieldHandler
//                                        confirm:confirmHandler
//                                         cancel:cancelHandler];
//    
//}
//
//#pragma mark ================懒加载=================
//- (MBProgressHUD *)hud {
//    if (!_hud) {
//        MBProgressHUD *hud = [[MBProgressHUD alloc] initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
//        [[UIApplication sharedApplication].keyWindow addSubview:hud];
//        hud.backgroundView.style = MBProgressHUDBackgroundStyleSolidColor;
//        hud.backgroundView.color = [UIColor colorWithWhite:0.f alpha:.2f];
//        hud.bezelView.color  = [UIColor whiteColor];
//        _hud = hud;
//    }
//    return _hud;
//}
//
//
//- (void)loadView {
//    if (self.banScreenshot) {
//        if (@available(iOS 13.2, *)) {
//            self.view = [MAScreenShieldView creactWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
//        }else{
//            [super loadView];
//        }
//    }else{
//        [super loadView];
//    }
//    self.view.userInteractionEnabled = YES;
//    self.view.backgroundColor = [UIColor whiteColor];
//}
//

@end
